jQuery(document).ready(function($) { //$('#cep_casa').numpad(); switchButton(); $('.navbar-toggle').click(function(event) { event.preventDefault(); $(this).toggleClass('collapsed'); $('.navbar-main-navigation').toggleClass('in'); $('#wpadminbar').toggleClass('navbar-in'); if($('.navbar-main-navigation').hasClass('in')){ $(window).scroll(function () { $(window).scrollTop(0); }); }else{ $(window).off('scroll'); } }); $('.slides-menu .slide-anchor').click(function(event) { event.preventDefault(); $('.slides-menu .slide-anchor').removeClass('active'); $(this).addClass('active'); var slide = $(this).attr('href'); slide = $(slide); if(slide.hasClass('active')){ return; }else{ $('.slides .item').not(slide).removeClass('active'); slide.addClass('active'); } }); owlSeguradoras = $('#seguradoras .owl-carousel'); owlSeguradoras.owlCarousel({ loop:true, margin:10, nav:true, autoplay: true, navText:'', responsive:{ 0:{ items:1 }, 600:{ items:3 }, 1000:{ items:5 } } }); $('.testimonials .testimonials-slider').owlCarousel({ loop:false, margin:0, dots:false, nav: true, autoplay: true, //lazyLoad:true, navText: '', responsive:{ 0:{ items:1 } } }); var $validator = $("#insurance-form-auto").validate({ // rules: { // // emailfield: { // // required: true, // // email: true, // // minlength: 3 // // }, // nome: { // required: true, // minlength: 3 // }, // // urlfield: { // // required: true, // // minlength: 3, // // url: true // // } // }, // messages: { // name: { // required: "Nome é obrigatório", // minlength: jQuery.validator.format("At least {0} characters required!") // } // // email: { // // required: "We need your email address to contact you", // // email: "Your email address must be in the format of name@domain.com" // // } // } }); var $validatorhouse = $("#insurance-form-house").validate({ // rules: { // // emailfield: { // // required: true, // // email: true, // // minlength: 3 // // }, // nome: { // required: true, // minlength: 3 // }, // // urlfield: { // // required: true, // // minlength: 3, // // url: true // // } // }, // messages: { // name: { // required: "Nome é obrigatório", // minlength: jQuery.validator.format("At least {0} characters required!") // } // // email: { // // required: "We need your email address to contact you", // // email: "Your email address must be in the format of name@domain.com" // // } // } }); var $validatorapartament = $("#insurance-form-apartament").validate({ // rules: { // // emailfield: { // // required: true, // // email: true, // // minlength: 3 // // }, // nome: { // required: true, // minlength: 3 // }, // // urlfield: { // // required: true, // // minlength: 3, // // url: true // // } // }, // messages: { // name: { // required: "Nome é obrigatório", // minlength: jQuery.validator.format("At least {0} characters required!") // } // // email: { // // required: "We need your email address to contact you", // // email: "Your email address must be in the format of name@domain.com" // // } // } }); $( "#nome" ).rules( "add", { required: true, minlength: 3, messages: { nome: { required: "Nome é obrigatório", minlength: jQuery.validator.format("At least {0} characters required!"), } // email: { // required: "We need your email address to contact you", // email: "Your email address must be in the format of name@domain.com" // } } }); $( ".complemento_apartament" ).rules( "add", { required: false, }); $( ".data_vencimento_apartament" ).rules( "add", { required: false, }); $( ".bonus_input_apartament" ).rules( "add", { required: false, }); // $('.insurance-form#insurance-form-auto').bootstrapWizard({ // 'onTabShow': function(tab, navigation, index) { // var $total = navigation.find('li').length; // var $current = index+1; // var $percent = ($current/$total) * 100; // $('#rootwizard').find('.bar').css({width:$percent+'%'}); // $('#insurance-form-auto .nav li.active').removeClass('done'); // }, // 'onTabClick': function(tab, navigation, index) { // // console.log('on tab click disabled'); // return false; // }, // 'onNext': function(tab, navigation, index) { // var $valid = $("#insurance-form-auto").valid(); // // console.log('next'); // // console.log('valid? '+$valid); // $('#insurance-form-auto .nav li').removeClass('done'); // $('#insurance-form-auto .nav li').each(function(index, el) { // if($valid && $(this).hasClass('active')){ // $(this).addClass('done'); // return false; // } // else if($(this).hasClass('active') && !$valid){ // return false; // }else{ // $(this).addClass('done'); // } // }); // if(!$valid) { // $validator.focusInvalid(); // return false; // } // }, // 'onPrev': function(tab, navigation, index) { // $('#insurance-form-auto .nav li').removeClass('done'); // $('#insurance-form-auto .nav li').each(function(index, el) { // if($(this).hasClass('active')){ // $(this).removeClass('done'); // } // }); // }, // }); // $('.insurance-form#insurance-form-house').bootstrapWizard({ // onTabShow: function(tab, navigation, index) { // var $total = navigation.find('li').length; // var $current = index+1; // var $percent = ($current/$total) * 100; // $('#rootwizard').find('.bar').css({width:$percent+'%'}); // $('#insurance-form-house .nav li.active').removeClass('done'); // }, // 'onTabClick': function(tab, navigation, index) { // // console.log('on tab click disabled'); // return false; // }, // 'onNext': function(tab, navigation, index) { // var $valid = $("#insurance-form-house").valid(); // // console.log('next'); // // console.log('valid? '+$valid); // $('#insurance-form-house .nav li').removeClass('done'); // $('#insurance-form-house .nav li').each(function(index, el) { // if($valid && $(this).hasClass('active')){ // $(this).addClass('done'); // return false; // } // else if($(this).hasClass('active') && !$valid){ // return false; // }else{ // $(this).addClass('done'); // } // }); // if(!$valid) { // $validatorhouse.focusInvalid(); // return false; // } // }, // 'onPrev': function(tab, navigation, index) { // $('#insurance-form-house .nav li').removeClass('done'); // $('#insurance-form-house .nav li').each(function(index, el) { // if($(this).hasClass('active')){ // $(this).removeClass('done'); // } // }); // }, // }); // wizardApartment = $('.insurance-form#insurance-form-apartament').bootstrapWizard({ // onTabShow: function(tab, navigation, index) { // var $total = navigation.find('li').length; // var $current = index+1; // var $percent = ($current/$total) * 100; // $('#rootwizard').find('.bar').css({width:$percent+'%'}); // $('#insurance-form-apartament .nav li.active').removeClass('done'); // }, // 'onTabClick': function(tab, navigation, index) { // // console.log('on tab click disabled'); // return false; // }, // 'onNext': function(tab, navigation, index) { // var $valid = $("#insurance-form-apartament").valid(); // // console.log('next'); // // console.log('valid? '+$valid); // $('#insurance-form-apartament .nav li').removeClass('done'); // $('#insurance-form-apartament .nav li').each(function(index, el) { // if($valid && $(this).hasClass('active')){ // $(this).addClass('done'); // return false; // } // else if($(this).hasClass('active') && !$valid){ // return false; // }else{ // $(this).addClass('done'); // } // }); // if(!$valid) { // $validatorapartament.focusInvalid(); // return false; // } // }, // 'onPrev': function(tab, navigation, index) { // $('#insurance-form-apartament .nav li').removeClass('done'); // $('#insurance-form-apartament .nav li').each(function(index, el) { // if($(this).hasClass('active')){ // $(this).removeClass('done'); // } // }); // }, // }); // $('.insurance-form#insurance-form-auto').bootstrapWizard({ // onTabShow: function(tab, navigation, index) { // var $total = navigation.find('li').length; // var $current = index+1; // var $percent = ($current/$total) * 100; // $('#rootwizard').find('.bar').css({width:$percent+'%'}); // } // }); // $('.insurance-form .finish').click(function(event) { // // var form = $($(this).context.parentElement.parentElement.parentElement); // event.preventDefault(); // var home = window.location.origin; // // var data_1 = form.serializeArray(); // // var request = $.ajax( // { // url: home + '/new/wp-admin/admin-ajax.php?action=send_insurance&' + new Date().getTime(), // type: 'POST', // data: JSON.stringify(data_1), // dataType: 'json', // processData: false, // contentType: 'application/json; charset=utf-8', // success: function(res) // { // //console.log(res); // if(!res.result) // { // var classAllert = 'alert-danger'; // //console.log(res.result); // console.log(res.errors); // var message = res.errors; // } // else // { // var classAllert = 'alert-success'; // var message = 'Seu pedido de cotação foi enviado com sucesso.'; // } // form.find('#content-alert').html( // '
'+ // '' + // message + // '
'); // form.find('#insurance-alert').show(); // }, // error: function(e) // { // console.log(e); // } // }); // }); $('.insurance-form').submit(function( event ) { event.preventDefault(); var home = window.location.origin; var btn = $(this).find(":submit"); var id_form = btn.attr('id'); var data_1 = $(this).serializeArray(); var name = value = $("#nome").val(); var request = $.ajax( { url: home + '/wp-admin/admin-ajax.php?' + new Date().getTime(), type: 'POST', data: {action: 'send_insurance', resposta: data_1, id_form: id_form}, dataType: 'json', success: function(res) { if(!res.result) { var classAllert = 'alert-danger'; var message = res.errors; $('#content-alert').html( '
'+ '' + message + '
'); $('#insurance-alert').show(); } else { var classAllert = 'alert-success'; var message = 'Seu pedido de cotação foi enviado com sucesso.'; if(id_form == 'insurance-apartament' || id_form == 'insurance-house'){ $('#valorcotacao').html( // console.log( '
' +' 4x de R$ ' + (res.valor/4).toFixed(2) + '' +'sem juros
Valor Total: R$'+res.valor.toFixed(2)+'
' +'
' +'
' +'Formas de Pagamento:' +'1x de R$ '+res.valor.toFixed(2)+' sem juros - Total R$ '+res.valor.toFixed(2)+'' +'2x de R$ '+(res.valor/2).toFixed(2)+' sem juros - Total R$ '+res.valor.toFixed(2)+'' +'3x de R$ '+(res.valor/3).toFixed(2)+' sem juros - Total R$ '+res.valor.toFixed(2)+'' +'4x de R$ '+(res.valor/4).toFixed(2)+' sem juros - Total R$ '+res.valor.toFixed(2)+'' +'
' +''+name+', entraremos em contato em breve.' ); $('#insurance-alert').show(); }else { $('#content-alert').html( '
'+ '' + message + '
'); $('#insurance-alert').show(); } } btn.removeClass('disabled'); }, error: function(e) { console.log(e); btn.removeClass('disabled'); } }); $(this).attr("disabled", false); }); $('#placa').on('keyup', function (e) { e.preventDefault(); var valueSelected = this.value; // console.log('value ', valueSelected); var home = window.location.origin; var request = $.ajax( { url: home + '/wp-admin/admin-ajax.php?' + new Date().getTime(), type: 'POST', data: {action: 'get_placa', placa: valueSelected}, dataType: 'json', success: function(res) { // console.log(res); }, error: function(e) { // console.log(e); } }); // console.log(request); }); $('#marca_veiculo').on('change', function (e) { e.preventDefault(); var optionSelected = $("option:selected", this); var valueSelected = this.value; // console.log('value', valueSelected); var select_modelo = $('#modelo_veiculo'); var home = window.location.origin; var request = $.ajax( { url: home + '/wp-admin/admin-ajax.php?' + new Date().getTime(), type: 'POST', data: {action: 'get_modelo_veiculo', id_marca: valueSelected}, dataType: 'json', success: function(res) { // console.log(res); select_modelo.empty(); $.each(res, function () { select_modelo.append($("